﻿<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>GPG生成密钥对</title>
</head>
<body>
<div id="wmd-preview" class="wmd-preview"><div class="md-section-divider"></div><div class="md-section-divider"></div><h1 data-anchor-id="anlu" id="gpg生成密钥对">GPG生成密钥对</h1><hr><div class="md-section-divider"></div><h2 data-anchor-id="rt0f" id="安装版本234">安装（版本2.3.4）</h2><p data-anchor-id="cgpg">Windows 系统，可以下载 Gpg4win 软件来生成密钥对。<a href="https://www.gpg4win.org/download.html" target="_blank">https://www.gpg4win.org/download.html</a> <br>
推荐使用 Gpg4win-Vanilla 版本，因为它仅包括 GnuPG，这个工具才是我们所需要的。 <br>
Linux 系统，直接从源中安装gpg软件包就行。</p><div class="md-section-divider"></div><h2 data-anchor-id="ccdj" id="gpggpg2">gpg/gpg2</h2><blockquote data-anchor-id="d4vr" class="white-blockquote">
  <p>gpg分为gpg和gpg2，需要看自己的maven使用的哪个gpg，再生成对应的gpg密钥。</p>
</blockquote><div class="md-section-divider"></div><h3 data-anchor-id="d5wl" id="window-cygwin">window cygwin</h3><div class="md-section-divider"></div><pre class="prettyprint linenums prettyprinted" data-anchor-id="ch7t"><ol class="linenums"><li class="L0"><code><span class="pln">apt</span><span class="pun">-</span><span class="pln">cyg install gnupg</span></code></li></ol></pre><div class="md-section-divider"></div><h1 data-anchor-id="bjft" id="如果使用window以下操作在cmd命令行中进行">如果使用window以下操作在cmd命令行中进行</h1><div class="md-section-divider"></div><h2 data-anchor-id="9oyl" id="查看是否安装成功">查看是否安装成功</h2><div class="md-section-divider"></div><pre class="prettyprint linenums prettyprinted" data-anchor-id="dcc0"><ol class="linenums"><li class="L0"><code><span class="pln">gpg </span><span class="pun">--</span><span class="pln">version</span></code></li></ol></pre><div class="md-section-divider"></div><h2 data-anchor-id="l783" id="生成密钥对">生成密钥对</h2><div class="md-section-divider"></div><pre class="prettyprint linenums prettyprinted" data-anchor-id="wv0w"><ol class="linenums"><li class="L0"><code><span class="pln"> gpg </span><span class="pun">--</span><span class="pln">gen</span><span class="pun">-</span><span class="pln">key</span></code></li></ol></pre><div class="md-section-divider"></div><h2 data-anchor-id="miu7" id="查看公钥私钥">查看公钥私钥</h2><div class="md-section-divider"></div><pre class="prettyprint linenums prettyprinted" data-anchor-id="4m44"><ol class="linenums"><li class="L0"><code><span class="pln">gpg </span><span class="pun">--</span><span class="pln">list</span><span class="pun">-</span><span class="pln">keys</span></code></li><li class="L1"><code></code></li><li class="L2"><code><span class="pun">/</span><span class="pln">home</span><span class="pun">/</span><span class="pln">CK</span><span class="pun">/.</span><span class="pln">gnupg</span><span class="pun">/</span><span class="pln">pubring</span><span class="pun">.</span><span class="pln">gpg</span></code></li><li class="L3"><code><span class="pun">---------------------------</span></code></li><li class="L4"><code><span class="pln">pub   </span><span class="lit">2048R</span><span class="pun">/</span><span class="lit">30509BA4</span><span class="pln"> </span><span class="lit">2017</span><span class="pun">-</span><span class="lit">09</span><span class="pun">-</span><span class="lit">21</span></code></li><li class="L5"><code><span class="pln">uid                  cuiyuqiang </span><span class="pun">(</span><span class="pln">web</span><span class="pun">框架)</span><span class="pln"> </span><span class="pun">&lt;</span><span class="pln">yuqiang</span><span class="pun">.</span><span class="pln">cui@gmail</span><span class="pun">.</span><span class="pln">com</span><span class="pun">&gt;</span></code></li><li class="L6"><code><span class="kwd">sub</span><span class="pln">   </span><span class="lit">2048R</span><span class="pun">/</span><span class="lit">7B7AA679</span><span class="pln"> </span><span class="lit">2017</span><span class="pun">-</span><span class="lit">09</span><span class="pun">-</span><span class="lit">21</span></code></li></ol></pre><p data-anchor-id="zifm">其中 <strong>30509BA4</strong> 是需要传到服务器的</p><div class="md-section-divider"></div><h2 data-anchor-id="3osv" id="将公钥发布到-pgp-密钥服务器">将公钥发布到 PGP 密钥服务器</h2><div class="md-section-divider"></div><pre class="prettyprint linenums prettyprinted" data-anchor-id="kjoq"><ol class="linenums"><li class="L0"><code><span class="pln">gpg </span><span class="pun">--</span><span class="pln">keyserver hkp</span><span class="pun">:</span><span class="com">//keyserver.ubuntu.com --send-keys 30509BA4</span></code></li></ol></pre><div class="md-section-divider"></div><h2 data-anchor-id="0wxv" id="查询公钥是否发布成功">查询公钥是否发布成功</h2><div class="md-section-divider"></div><pre class="prettyprint linenums prettyprinted" data-anchor-id="rjdt"><ol class="linenums"><li class="L0"><code><span class="pln"> gpg </span><span class="pun">--</span><span class="pln">keyserver hkp</span><span class="pun">:</span><span class="com">//keyserver.ubuntu.com --recv-keys 30509BA4</span></code></li><li class="L1"><code></code></li><li class="L2"><code><span class="pln"> </span><span class="pun">注：使用</span><span class="pln">idea</span><span class="pun">发布代码时，如果退出</span><span class="pln">idea</span><span class="pun">重新登录在发布</span></code></li></ol></pre><div class="md-section-divider"></div><h2 data-anchor-id="qbr7" id="查看密钥">查看密钥</h2><div class="md-section-divider"></div><pre class="prettyprint linenums prettyprinted" data-anchor-id="lzrx"><ol class="linenums"><li class="L0"><code><span class="pln">gpg </span><span class="pun">--</span><span class="kwd">delete</span><span class="pun">-</span><span class="pln">keys id</span></code></li><li class="L1"><code></code></li><li class="L2"><code><span class="pln">gpg </span><span class="pun">--</span><span class="kwd">delete</span><span class="pun">-</span><span class="pln">secret</span><span class="pun">-</span><span class="pln">key id</span></code></li></ol></pre><div class="md-section-divider"></div><h2 data-anchor-id="okp1" id="git设置全局密钥">git设置全局密钥</h2><div class="md-section-divider"></div><pre class="prettyprint linenums prettyprinted" data-anchor-id="y6wo"><ol class="linenums"><li class="L0"><code><span class="pln">git config </span><span class="pun">--</span><span class="kwd">global</span><span class="pln"> user</span><span class="pun">.</span><span class="pln">signingkey </span><span class="lit">30509BA4</span></code></li></ol></pre></div>
</body>
</html>